package com.sbtr.business.trainingmodel.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.sbtr.business.trainingmodel.entity.ProjectEstimate;
import com.sbtr.business.trainingmodel.dto.ProjectEstimateDto;

import com.sbtr.business.trainingmodel.service.ProjectEstimateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sbtr.business.trainingmodel.mapper.ProjectEstimateMapper;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sbtr.common.PageDto;
import com.sbtr.util.PageDtoUtils;
import org.springframework.transaction.annotation.Transactional;

/**
 * 项目预估设置 Service接口实现类
 *
 * @author dgl
 * @since  2024-01-31
 */
@Transactional
@Service
public class ProjectEstimateServiceImpl extends ServiceImpl<ProjectEstimateMapper,ProjectEstimate> implements ProjectEstimateService {

    @Autowired
    ProjectEstimateMapper projectEstimateMapper;

    @Override
    public PageDto<ProjectEstimate> pageList(ProjectEstimateDto projectEstimateDto) {

        IPage<ProjectEstimate> page = new Page<>();
        page.setSize(projectEstimateDto.getPageSize());
        page.setCurrent(projectEstimateDto.getPage());
        page = projectEstimateMapper.selectPages(page, BeanUtil.beanToMap(projectEstimateDto));
        PageDto<ProjectEstimate> r = PageDtoUtils.getPageDtoByIPage(page, ProjectEstimate.class);

        return r;
    }
}

